(def first (lambda (list) 
	(. com.pavlinic.mylisp.javaLibrary.Lists first (expr list))))	

(def rest (lambda (list) 
	(. com.pavlinic.mylisp.javaLibrary.Lists rest (expr list))))	
	
(def length (lambda (list) 
	(. com.pavlinic.mylisp.javaLibrary.Lists length (expr list))))	
	
(def cons (lambda (head tail)
	(. com.pavlinic.mylisp.javaLibrary.Lists cons (expr head) (expr tail))))
	
(def reduce (lambda (op lst)
	(if (= (length lst) 1) 
		(first lst)
		(op (first lst) (reduce op (rest lst))
		))))
		
(def list (lambda (&args) args))

(def second (lambda (lst) (first (rest lst))))

(def empty? (lambda (lst) (= 0 (length lst))))

(def assoc (lambda (item pairlist)
	(if (empty? pairlist) null 
		(if (= item (first (first pairlist))) (first pairlist)
			(assoc item (rest pairlist))))
))

(def apply (lambda (fun lst)
	(. com.pavlinic.mylisp.javaLibrary.Lists apply (expr fun) (expr lst))
))

(def appendTwo (lambda (a b)
	(. com.pavlinic.mylisp.javaLibrary.Lists append (expr a) (expr b))
))

(def append (lambda (&lists)
	(reduce appendTwo lists)
))
	